import axios from 'axios';

export interface AreaRecord {
  id: number;
  alias: string;
  x_num: number;
  y_num: number;
  total_seats: number;
  sold_seats: number;
  unavailable_seats: number;
}

export function queryAreaList() {
  return axios.get<AreaRecord[]>('/api/areas');
}

// /api/areas/{id}/seats
export interface SeatRecord {
  id: number;
  area_id: number;
  seat_number: string;
  row: number;
  col: number;
  status: number;
}

export interface SeatRowsRecord {
  row: number;
  cols: SeatRecord[];
}

export function querySeatList(areaId: number) {
  return axios.get<SeatRowsRecord[]>(`/api/areas/${areaId}/seats`);
}

// 座位状态
export function updateSeatStatus(areaId: number, ids: number[], status: number) {
  return axios.post(`/api/areas/${areaId}/seats`, { ids, status });
}
